package javacore.fundamentals.garbage;

class A implements Runnable{
	String name;
	
	public A() {
		name = "";
	}
	
	@Override
	protected void finalize() throws Throwable {
		super.finalize();
		System.out.println("abc");
	}

	@Override
	public void run() {
		System.out.println("11111111111111");
	}
}


public class FirstExample {
	public static void main(String[] args) {
		Runtime rt = Runtime.getRuntime();
		System.out.println("JVM free memory before running gc: " + rt.freeMemory());
		A a = new A();
		new Thread(a).start();
		System.out.println("JVM free memory before running gc: " + rt.freeMemory());
		rt.gc();
		System.out.println("JVM free memory after running gc: " + rt.freeMemory());
		
	}
}
